#!/usr/bin/env perl

BEGIN {
	push @INC,"../libs";
}

use gri2_rsatcp;

($a,$b)=gri2_rsatcp::gen_rsa_key_pair({bits=>2048,
	email           => "simon\@test",
	"username/host" => "myuid/myhost",
	comment         => "This is a test public key."
});
if($a==0) {
	print STDERR "Failed to create RSA key pair!!\n";
	print STDERR "Error: $_\n" foreach(@$b);
	exit;
}

$rsa=$b;

($a,$b)=gri2_rsatcp::write_public_key({
	rsa 		=> $rsa,
	file		=> "/tmp/keys/test.public",
	});

if($a==0) {
	print STDERR "Failed to write public key: $b->[0]\n";exit;
}

($a,$b)=gri2_rsatcp::write_private_key({
	rsa 		=> $rsa,
	file		=> "/tmp/keys/test.private",
	});

if($a==0) {
	print STDERR "Failed to write private key: $b->[0]\n";exit;
}
